# coding: utf-8 
import wsgiref.handlers
from google.appengine.ext import webapp
from google.appengine.ext import db
import logging, os
import datetime
from xml.dom import minidom
	
class User(db.Model):
	"""
	Model which represents an user
	@author: guiocavalcanti
	"""
	
	username = db.StringProperty(required=True)
	password = db.StringProperty(required=True)
	firstName = db.StringProperty(required=True)
	lastName = db.StringProperty()
	email = db.EmailProperty(required=True)
	content = db.TextProperty()
	
	def __unicode__(self):
		return self.name
		
	def getUsername(self):
		return self.username
		
	def getPassword(self):
		return self.password
		
	def getFirstName(self):
		return self.firstName
		
	def getLastName(self):
		return self.lastName
		
	def getEmail(self):
		return self.email
		
	def getContent(self):
		return self.content
	
	def setPassword(self, newPassword):
		self.passowrd = newPassword
		
	def setName(self, firstName=None, lastName=None):
		"""
		Set user first and last name, if firstName or lastName are != None
		@param firstName: user's first name
		@param lastName: user's last name (not in use)
		"""
		if firstName:
			self.firstName = firstName
		
		if lastName:
			self.lastName = lastName
			
	def setEmail(self, newEmail):
		self.email = newEmail
		
	def setContent(self, content):
		self.content = content
				
	def checkPass(self, password):
		"""
		Checks user password
		@return: True if password matches, otherwise False
		"""
		return self.getPassword() == password
		
		

